package com.frostmourne.mxsattributeinventory.hooks;

import com.frostmourne.mxsattributeinventory.MXSAttributeInventory;
import com.frostmourne.mxsattributeinventory.utils.FileUtils;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import org.bukkit.entity.Player;

public class PAPIHook extends PlaceholderExpansion {

    @Override
    public String onPlaceholderRequest(Player player, String params) {
        if (params.contains("_")){
            String[] str = params.split("_");
            if (str[0].equalsIgnoreCase("item")){
                String invName = str[1];
                int slot = Integer.parseInt(str[2]);
                if (FileUtils.getItemByNameAndSlot(player,invName,slot) == null){
                    return "§8无";
                }else {
                    return FileUtils.getItemByNameAndSlot(player, invName, slot).getItemMeta().getDisplayName();
                }
            }
        }
        return "§cN/A";
    }

    @Override
    public String getIdentifier() {
        return "mxsai";
    }

    @Override
    public String getAuthor() {
        return MXSAttributeInventory.getPlugin().getDescription().getAuthors().toString();
    }

    @Override
    public String getVersion() {
        return MXSAttributeInventory.getPlugin().getDescription().getVersion();
    }
}
